<template>
  <el-card class="box-card">
    <div slot="header" class="clearfix">
      <span>商品统计</span>
    </div>
    <div class="text item" >
      <div id="main" style="height:400px"></div>
    </div>
  </el-card>
</template>

<script>
import * as echarts from "echarts";

export default {
  name: "GoodsTotal",
  data() {
    return {};
  },
  created() {
    this.initEcharts();
  },
  methods: {
    initEcharts() {
      // 新建一个promise对象
	let newPromise = new Promise((resolve) => {
		resolve()
	})
	//然后异步执行echarts的初始化函数
	newPromise.then(() => {
		// 基于准备好的dom，初始化echarts实例
      var myChart = echarts.init(document.getElementById('main'));
      // 绘制图表
      myChart.setOption({
        xAxis: {
          type: "category",
          data: ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"],
        },
        yAxis: {
          type: "value",
        },
        series: [
          {
            data: [120, 200, 150, 80, 70, 110, 130],
            type: "bar",
          },
        ],
      });
 
	})

         },
  },
};
</script>

<style>

</style>
